{% load static from staticfiles %}
<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script src="{{ STATIC_URL }}js/jquery.validate.min.js"></script>

<script>
var isBuyHidden = true;
$(document).ready(function() {
  $("#buyLink").click(function() {
  if (isBuyHidden == true) 
  (
      $("#buySection").show(1000, function() { isBuyHidden = false})
  )
  else
  (
       $("#buySection").hide(1000, function() { isBuyHidden = true})
  )
  } )


$("#requestApproveHandler").validate({
	rules: {
		credit_ammount: {
			required: true,
			min: {{min_pts_amount}}
		}
	},
	messages: {
		credit_ammount: {
			required: "Please enter some points amount",
			min: "You cannot purchase less than " +  {{min_pts_amount}} + " points"
		},
	}
});
 

  $(document).ready(function() {  
	    $('#english_link').click(function(e) {
	    	var form = $('#lang_code');
	    	form.append('<input type="hidden" name="language" value="en" />');
	    	var str = form.serialize();
	        $.ajax({
	            type: 'POST',
	            url: "/member/lang/set/",
	            data: str,
	            success: function(data){
	            	form.submit();
	        }  
	        });

	        return true;
	    });
	});
  
  $(document).ready(function() {  
	    $('#spanish_link').click(function(e) {
	    	var form = $('#lang_code');
	    	form.append('<input type="hidden" name="language" value="es" />');
	    	var str = form.serialize();
	        $.ajax({
	            type: 'POST',
	            url: "/member/lang/set/",
	            data: str,
	            success: function(data){
	            	form.submit();
	        }  
	        });
            

	        return true;
	    });
	});
  
  $(document).ready(function() {  
	    $('#japanese_link').click(function(e) {
	    	var form = $('#lang_code');
	    	form.append('<input type="hidden" name="language" value="ja" />');
	    	var str = form.serialize();
	        $.ajax({
	            type: 'POST',
	            url: "/member/lang/set/",
	            data: str,
	            success: function(data){
	            	form.submit();
	        }  
	        });
            
	        return true;
	    });
	});
}
);
</script>
</head>

{% load i18n %}


<form action="{% url 'set_language' %}" method="post" id="lang_code">
{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<a href="#" id="english_link" class="icon-plus" >English</a>
<a href="#" id="spanish_link" class="icon-plus" >Español</a>
<a href="#" id="japanese_link" class="icon-plus" >日本語</a>
</form>

Welcome to CashGirls
<br/>

{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->

{% if user.username %}
  Hi {{ user.username }} <br/>
     Current points: {{ user.points }}  <br/>
    {% if not user.age %}
      <br/>

     <a href="#" id="buyLink"> {% trans "Buy Points" %}</a> <br>

     <div id="buySection" style="display: none;">
     <form action="/member/points/payment/" name="requestApproveHandler" id="requestApproveHandler" method="post" onsubmit="return validateForm()">

       <input id="credit_ammount" name="credit_ammount"/>
       <input value="buy" type="submit" id="buy" name="buy">
       {% csrf_token %}

     </form>
     </div>
  {% endif%}
  
  <a href="/member/logout/"> Logout </a> <br/>
  <a href="/member/myAccount/"> My account </a> <br/>
{% else %}
<form name="login" method="post" action="/member/validate/">
   username: <input name="username"/> <br/>
   password: <input name="password"/>  <br/>
   {% csrf_token %}
   <input type="submit" value="login"/> 
</form>

{% if messages %}
    {% for message in messages %}
       {{ message }} <br/>
    {% endfor %}
{% endif %}
   <a href="/member/shopperSignUpForm/"> Sign in </a> <br/>
   <a href="/member/signUpForm/"> I want to become a CashGirl </a>
   <br/>
{% endif %} 
Our top models   
<br/><br/>
{% for user, profile_image_thumbnail in users_paginator %}

   <a href="/profile/{{user.id}}"> {{user.username}} </a> <img src="{{ MEDIA_URL }}{{profile_image_thumbnail}}" width="60" height="60"/>
    <br/>
{% endfor %}   

<div class="pagination">
    <span class="step-links">
        {% if users_paginator.has_previous %}
            <a href="?page={{ users_paginator.previous_page_number }}">previous</a>
        {% endif %}

        <span class="current">
            Page {{ users_paginator.number }} of {{ users_paginator.paginator.num_pages }}.
        </span>

        {% if users_paginator.has_next %}
            <a href="?page={{ users_paginator.next_page_number }}">next</a>
        {% endif %}
    </span>
</div>